
var ItemModel = Backbone.Model.extend({});
var ItemList = Backbone.Collection.extend({
	model: ItemModel
});	

var ViewData=(function(){
	var conf = {

		// layoutUI:[
			// {
				// entry:{1: "FlipButtion"}
				// ,sub:{
					// menu: ["FlipButton", ["View"]],
				// } 
			// }
		// ],
		asset:{
			combo: [
			new ItemModel({
				hint : "Asset Group",
				opts : []
			})
			
			, new ItemModel({
				hint : "Category",
				opts : []
			})],
			groups:{
				// "Commodity": ["CCS","CFD","CFX","CSO","CST","ECS","EFX","ESO","EST","TCS","TFX","TST","WRP"],
				// "Futures Option": ["CMO","EOP","TOP","WOP"],
				// "Cash Option": ["BOP","COP","IRO"],
				// "Derivitive Future": ["CMF","CSP","EFU","ESP","ESW","TFU","WFU","WSP","TSP"],
				// "Financial Index": ["CIX","ENI","TIN"]

			},
			tips: new ItemList([]),
			sticky: new ItemModel({
				val : ['']
			}),
			tips_type:{},
			tabs: new ItemList([]),
			search:{val:"", type:""},
			action:1, //1 for search, 0 for add
			addType: 1 // 1 for quote, 0 for issue
		},
		
		root:{
			input : new ItemModel({
				fields:
					[["Root","Root", 0], ["Tag","Tag", 1],["Desc", "Description", 2],["State", "State", 6, ["AC", "DC"]]]
				,block:"Root"
			}),
			alert:new ItemModel({msg:''}),
			table_head: [["Root"], ["Tag"], ["Description",{css:"min-width: 200px;width:200px"}], ["C #"], ["CM #"], ["Switch Months"], ["State"], ["Pricing Unit"],[ "Future Asset Type"]],
			table : new ItemModel({data:[
				// ["R2oot", "Tag", "Description", "C#", "CM#", "Switch Months", "State", "Pricing Unit", "Future Asset Type"]
				], block: "Root"}
			),
			sort:[0,1,2],
			tabs: new ItemList([]),
			action:1, //1 for search, 0 for add
			search:{val:""},
			val: ""
		}
		,
		URIC:{
			input : new ItemModel({
				fields:
					[["Stub","RIC Stub", 1], ["Under", "Underlying RIC", 2],["Alias","URIC Alias", 3],["Leap?", "Leap", 4, ["All", "Yes", "No"]]]
				,block:"URIC"
			}),
			alert:new ItemModel({msg:''}),
			table_head: [["Cash or Future"],["RIC Stub"], ["Underlying RIC"], ["URIC Alias"], ["Leaps"], ["Asset Root"], ["Month Offset"], ["Excersice style"], ["Method of Delivery"],[ "Tick Value"]],
			table : new ItemModel({data:[
				], block: "URIC"}
			),
			sort:[1,3],
			tabs: new ItemList([]),
			action:1,
			search:{val:""},
			val: ""
		}
		,		
		err:{
			char2: "The input length should be <strong> at least 2</strong> characters."
			,norecord: "<strong> No Record Found</strong> for this search. Please change the criteria."
			,notsupportquery: "Only search this type of data is not supported."
			,empty: "This field should <strong>NOT</strong> be empty!"
			// notag: "The Type is needed for <strong>NOT</strong> be empty!",
			,login: "Username & Password didn't match."
			,emptyUser: "Username cannot be empty"
			,emptyPwd: "Password cannot be empty"
		},
		LoginView:{
			alert:new ItemModel({msg:''})
		},

		LoginDefault:{
			Asset: 0,
			Bulk: 0,
			Root: 0,
			URIC: 0
		}
	};
	conf.Root = conf.root;
	conf.Asset = conf.asset;
	conf.Login = $.extend(true, {}, conf.LoginDefault);
	return conf;
})();
ViewData.layout=new ItemList([
		{
			title: 'Asset'
			, entry: 'Search' 
			, sub: ''
			, items: ViewData.asset.tabs				
		},
		{	title: 'Bulk' 
			,entry:'Upload'
			, sub: ''			
		},
		{	
			title: 'Root'
			, entry:'Search'
			, sub: ''
			, items: ViewData.root.tabs				
		},
		{	
			title: 'URIC', 
			entry:'Search', 
			sub: '',
			items: ViewData.URIC.tabs				
		
		},				
		{title: 'Root1', entry:'Body'},
		{title: 'URIC1', entry:'Body'}				
]);

var user_data={
	'tom':{
		usr: "tom",
		token: 123213,
		Asset:{"Commodity":["CFX","CSO","CST","ECS"], "Futures Option": ["CMO","EOP","TOP","WOP"]},
		Bulk: 0,
		Root:1,
		URIC:1		
	},
	'admin':{
		usr: "admin",
		token: 1234123,
		Asset:{
				"Commodity": ["CCS","CFD","CFX","CSO","CST","ECS","EFX","ESO","EST","TCS","TFX","TST","WRP"],
				"Futures Option": ["CMO","EOP","TOP","WOP"],
				"Cash Option": ["BOP","COP","IRO"],
				"Derivitive Future": ["CMF","CSP","EFU","ESP","ESW","TFU","WFU","WSP","TSP"],
				"Financial Index": ["CIX","ENI","TIN"]
		},
		Bulk: 1	,
		Root:1,
		URIC:1					
	}
}
var url ={
	base : "http://ddm/ddm/DDMPresentation.WCFLayer.DDMService.svc",
	ide: "/tips/0/blue",
	Root : "/root/0/1/blue",
	URIC : "/uric/0/1/blue",
	login: "/login/0/1/blue"

}